package com.atguigu.spzx.user.service.impl;

import com.atguigu.spzx.model.entity.user.UserAddress;
import com.atguigu.spzx.service.utils.AuthContextUtils;
import com.atguigu.spzx.user.mapper.UserAddressMapper;
import com.atguigu.spzx.user.service.UserAddressService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * ClassName: UserAddressServiceImpl
 * Package: com.atguigu.spzx.user.service.impl
 * Description:
 *
 * @Author 刘强
 * @Create 2024/7/17 17:11
 * @Version 1.0
 */
@Service
public class UserAddressServiceImpl implements UserAddressService {
    @Resource
    private UserAddressMapper userAddressMapper;
    /**
     * 获取用户的地址列表
     * @return
     */
    @Override
    public List<UserAddress> findUserAddressList() {
        Long userId = AuthContextUtils.get().getId();
        return userAddressMapper.findUserAddressList(userId);
    }

    /**
     * 根据id获取用户地址
     * @param id
     * @return
     */
    @Override
    public UserAddress getUserAddressById(Long id) {
        return userAddressMapper.getUserAddressById(id);
    }
}
